package com.pipi.ui.mvc;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.pipi.jpa.model.Home;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by pipi on 2017/8/11.
 */
@Controller
public class TestController {
    @GetMapping("/")
    public String index(){
//        data: [
//        {f1:'value11', f2:'value12'},
//        {f1:'value21', f2:'value22'}
//	]

        return "index";
    }
    @PostMapping("/demo/show/filename")
    @ResponseBody
    public String data(){
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("fileName","test");
        array.add(object);
        return array.toJSONString();
    }

    @PostMapping("/post/json")
    @ResponseBody
    public String testData(Home home,@RequestBody String abc) {
        return "yes";
    }

}
